import 'package:flutter/material.dart';

void main(List<String> args) {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: AppBarExample());
  }
}

class AppBarExample extends StatelessWidget {
  const AppBarExample({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('CODERWHY')),
      body: const MyAppBody(),
    );
  }
}

class MyAppBody extends StatelessWidget {
  const MyAppBody({super.key});

  @override
  Widget build(BuildContext context) {
    return const Demo();
  }
}

class Demo extends StatelessWidget {
  const Demo({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
      padding: const EdgeInsets.all(20),
      children: const [
        CirculateItem('apple', '1',
            'https://t7.baidu.com/it/u=657578767,2750473856&fm=193&f=GIF'),
        SizedBox(height: 10),
        CirculateItem('apple2', '2',
            'https://t7.baidu.com/it/u=1330338603,908538247&fm=193&f=GIF'),
        SizedBox(height: 10),
        CirculateItem('apple3', '3',
            'https://t7.baidu.com/it/u=2168645659,3174029352&fm=193&f=GIF'),
      ],
    );
  }
}

class CirculateItem extends StatelessWidget {
  final String title;
  final String desc;
  final String imgUrl;
  const CirculateItem(this.title, this.desc, this.imgUrl, {super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: const EdgeInsets.all(20),
        decoration: BoxDecoration(border: Border.all(width: 2)),
        child: Column(
          children: [
            Text(title, style: const TextStyle(fontSize: 30)),
            const SizedBox(height: 8),
            Text(desc),
            const SizedBox(height: 10),
            Image.network(
              imgUrl,
              fit: BoxFit.cover,
            )
          ],
        ));
  }
}

// 展示img
class MyAppbodyImage extends StatelessWidget {
  const MyAppbodyImage({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Expanded(
          flex: 1,
          child: Image.network(
              'https://t7.baidu.com/it/u=4198287529,2774471735&fm=193&f=GIF',
              fit: BoxFit.cover),
        ),
        Expanded(
            flex: 1,
            child: Image.asset('assets/image/1.jpg', fit: BoxFit.cover))
      ],
    );
  }
}
